home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_vol_nestwaypoints.cog < prev    next >
Text File  |  1999-11-15  |  10KB  |  348 lines

  1. # Jones 3D Cog Script
  2. #
  3. # vol_NestWayPoints.cog
  4. #
  5. # setup and run commies on a grid in the vol commie nest area
  6. #
  7. # [CMG]
  8. #
  9. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  10. # ========================================================================================
  11.  
  12. symbols
  13. #.......................MESSAGES.....................    
  14.     message     startup
  15.     message     entered
  16.     message     pulse
  17.     message        arrivedwpnt
  18.     message        killed
  19.     message        damaged
  20.     
  21.     
  22. #.......................ACTORS.....................    
  23.     thing       player                          local
  24.     
  25.     int            n_NumHuntingCommies=4            local            # 
  26.  
  27.     thing       t_commie00                         
  28.     thing       t_commie01                         
  29.     thing       t_commie02                         mask=0x409 # this will be the alert commie                         
  30.     thing       t_commie03                        # guy in room to right.
  31.     thing        t_commie04                        # this will be the sniper commie                         
  32.  
  33.     int     MESSENGER_COMMIE_INDEX=2    local  
  34.     int     RIGHT_ROOM_COMMIE_INDEX=3    local  
  35.     int     SNIPER_COMMIE_INDEX=4        local  
  36.  
  37. #.......................WAY POINTS.....................    
  38.     int            NUM_WAYPOINTS=18    local    
  39.     thing        t_ghost00
  40.     thing        t_ghost01
  41.     thing        t_ghost02
  42.     thing        t_ghost03
  43.     thing        t_ghost04
  44.     thing        t_ghost05
  45.     thing        t_ghost06
  46.     thing        t_ghost07
  47.     thing        t_ghost08
  48.     thing        t_ghost09
  49.     thing        t_ghost10
  50.     thing        t_ghost11
  51.     thing        t_ghost12
  52.     thing        t_ghost13
  53.     thing        t_ghost14
  54.     thing        t_ghost15
  55.     thing        t_ghost16
  56.     thing        t_ghost17
  57.  
  58. #.......................EVENT LOCATIONS.....................
  59.  
  60. #.......................TRIGGERS.....................
  61.     sector        way_trig    
  62.     sector        run_trig
  63.  
  64. #.......................TYPES.....................
  65.     AI            ai_sniper=com_2Hsniper.ai        local
  66.  
  67. #.......................SOUNDS.....................
  68.     sound        com_alertline=INXH1010.WAV        local        # "...capitalist stooge" 
  69.  
  70.  
  71. #.......................VARIABLES.....................
  72.     int            n_pos                            local                
  73.     int            b_IndyCrossed=0                    local                
  74.     int            b_MessengerSent=0                local
  75.     int            b_CommiesHunting=0                local                
  76.     int            b_MessengerStopped=0            local                
  77.     int            b_WpntsActive=0                    local
  78.  
  79.     vector        v_IndyPos                        local
  80.     vector        v_IndyLook                        local
  81.     vector        v_CommiePos                        local
  82.     vector        v_IndyToCommie                    local 
  83.     flex        f_dot                             local
  84.  
  85. #.......................CONSTANTS.....................
  86.     int     MESSENGER_FLEE_TO_WAYPOINT=7        local
  87.     int     MESSENGER_YELL_WAYPOINT=3        local
  88.  
  89.  
  90. #.......................SUBROUTINES.....................
  91.     flex    ActivateWaypoints            local
  92.     flex    DeactivateWaypoints            local
  93.     flex    SendMessenger                local
  94.  
  95. end
  96.  
  97. # ========================================================================================
  98.  
  99. code
  100.  
  101. startup:
  102.     Sleep(0.5);
  103.     player = GetLocalPlayerThing();
  104.     AISetClass(t_commie00[SNIPER_COMMIE_INDEX], ai_sniper);
  105.     
  106.     // Make sure this guy doesn't move until we want him to.
  107.     // He is the messenger.
  108.     AIEnableInstinct(t_commie00[MESSENGER_COMMIE_INDEX], "dodge", 0);
  109.     AIEnableInstinct(t_commie00[MESSENGER_COMMIE_INDEX], "humancombatmove", 0);
  110.     AIEnableInstinct(t_commie00[MESSENGER_COMMIE_INDEX], "basicfollow", 0);
  111.     AIEnableInstinct(t_commie00[MESSENGER_COMMIE_INDEX], "circlestrafe", 0);
  112.     AIEnableInstinct(t_commie00[MESSENGER_COMMIE_INDEX], "listen", 0);
  113.     
  114.     // Guy in room to right does not move until after messenger gets sent 
  115.     // so that he does not get in the way
  116.     AIEnableInstinct(t_commie00[RIGHT_ROOM_COMMIE_INDEX], "dodge", 0);
  117.     AIEnableInstinct(t_commie00[RIGHT_ROOM_COMMIE_INDEX], "humancombatmove", 0);
  118.     AIEnableInstinct(t_commie00[RIGHT_ROOM_COMMIE_INDEX], "basicfollow", 0);
  119.     AIEnableInstinct(t_commie00[RIGHT_ROOM_COMMIE_INDEX], "circlestrafe", 0);
  120.     AIEnableInstinct(t_commie00[RIGHT_ROOM_COMMIE_INDEX], "listen", 0);
  121.  
  122.     return;    
  123.     
  124. # ========================================================================================
  125. entered:    
  126.     if ((GetSenderRef() == way_trig) && (GetSourceRef() == player))
  127.     {
  128.         call ActivateWaypoints;    
  129.         SetPulse(0.1);
  130.     }
  131.     else if ((GetSenderRef() == run_trig) && (GetSourceRef() == player))
  132.     {
  133.         if (b_IndyCrossed == 0)
  134.         {
  135.             call SendMessenger;
  136.             b_IndyCrossed = 1;
  137.         }
  138.     }
  139.  
  140.     return;
  141.  
  142.  
  143. # ========================================================================================
  144. arrivedwpnt:
  145.     # if messenger reaches the hunt trigger, remaining commies are alerted, and attack
  146.     if((GetSenderRef() == t_commie00[MESSENGER_COMMIE_INDEX]) && (GetParam(0) == MESSENGER_YELL_WAYPOINT))
  147.     {
  148.         if (b_CommiesHunting == 0)
  149.         {
  150.             //Set some of the commies to patrol, or 'roam' in this case
  151.             #Print("Commies hunting");
  152.             #DebugPrint("Commies hunting");
  153.             
  154.             // Yell to wake up buddies
  155.             PlayVoice(t_commie00[MESSENGER_COMMIE_INDEX], com_alertline, 1.0, 0);    # wake up buddies
  156.  
  157.             // Send all hunting commies after Indy 
  158.             for(n_pos = 0; n_pos < n_NumHuntingCommies; n_pos = n_pos+1)
  159.             {
  160.                 if (t_commie00[n_pos] != -1)
  161.                 {
  162.                     AIEnableInstinct(t_commie00[n_pos], "roam", 1);
  163.                     // Messenger keeps going
  164.                     if (n_pos != MESSENGER_COMMIE_INDEX)
  165.                     {
  166.                         AIWpntHuntTarget(t_commie00[n_pos], 2.0, 0.0);
  167.                     }
  168.                 }
  169.             }
  170.                 
  171.             b_CommiesHunting = 1;
  172.         }
  173.  
  174.     }
  175.     if((GetSenderRef() == t_commie00[MESSENGER_COMMIE_INDEX]) && (GetParam(0) == MESSENGER_FLEE_TO_WAYPOINT))
  176.     {
  177.         if (!b_MessengerStopped)
  178.         {
  179.             b_MessengerStopped = 1;
  180.             // Stop the messenger.
  181.             AIStopFlee(t_commie00[MESSENGER_COMMIE_INDEX]);
  182.             AIClearSubMode(t_commie00[MESSENGER_COMMIE_INDEX], 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION. Was need for FleeToWpnt
  183.             AISetLookThing(t_commie00[MESSENGER_COMMIE_INDEX], t_ghost03);
  184.         }
  185.     }
  186.     
  187.     return;
  188.  
  189. # ========================================================================================
  190. killed:
  191. //    Print("Commie Killed");
  192. //    DebugPrint("Commie Killed");
  193.     
  194.     //Check for dead commies so as not to assign an instinct to a commie that no longer exists
  195.     for(n_pos = 0; n_pos < n_NumHuntingCommies; n_pos = n_pos+1)
  196.     {
  197.         if(GetSenderRef() == t_commie00[n_pos])
  198.         {
  199.             t_commie00[n_pos] = -1;
  200.         }
  201.     }
  202.     return;
  203.  
  204. # ========================================================================================
  205. damaged:
  206.     // If messenger takes damage he heads out immediately
  207.     if (GetSenderRef() == t_commie00[MESSENGER_COMMIE_INDEX])
  208.     {
  209. //        Print("Messenger Damaged");
  210. //        DebugPrint("Messenger Damaged");
  211.         call SendMessenger;
  212.     }
  213.  
  214.     return;
  215.  
  216. # ========================================================================================
  217. pulse:
  218.  
  219.     // When Indy can see the messenger commie it is time to send the messenger.
  220.     if ( (!b_MessengerSent) && (t_commie00[MESSENGER_COMMIE_INDEX] != -1))
  221.     {
  222.         v_IndyLook = GetThingLVec(player);
  223.         v_IndyPos = GetThingPos(player);
  224.         v_CommiePos = GetThingPos(t_commie00[MESSENGER_COMMIE_INDEX]);
  225.  
  226.         v_IndyToCommie = VectorNorm(VectorSub(v_CommiePos, v_IndyPos));
  227.         f_dot = VectorDot(v_IndyToCommie, v_IndyLook);
  228.  
  229.         // Check if Indy is facing toward the commie
  230.         if (f_dot > 0.707)
  231.         {
  232.             // Check for unobstructed Line of Sight between the two 
  233.             if (HasLos(t_commie00[MESSENGER_COMMIE_INDEX], player))
  234.             {
  235.                 // Stop checking for LOS to player  
  236.                 SetPulse(0.0);
  237.                 
  238.                 Sleep(0.5);
  239.                 PlayVoice(t_commie00[MESSENGER_COMMIE_INDEX], com_alertline, 1.0, 0);    # cuss at jones
  240.                 Sleep(0.5);
  241.  
  242.                 call SendMessenger;
  243.  
  244.             }
  245.         }
  246.     }
  247.  
  248.     return;
  249.  
  250.  
  251. # ========================================================================================
  252. SendMessenger:
  253.  
  254.     if (!b_MessengerSent)
  255.     {
  256.         #Print("Messenger Sent");
  257.         #DebugPrint("Messenger Sent");
  258.         
  259.         AIEnableInstinct(t_commie00[MESSENGER_COMMIE_INDEX], "dodge", 1);
  260.         AIEnableInstinct(t_commie00[MESSENGER_COMMIE_INDEX], "humancombatmove", 1);
  261.         AIEnableInstinct(t_commie00[MESSENGER_COMMIE_INDEX], "basicfollow", 1);
  262.         AIEnableInstinct(t_commie00[MESSENGER_COMMIE_INDEX], "circlestrafe", 1);
  263.         AIEnableInstinct(t_commie00[MESSENGER_COMMIE_INDEX], "listen", 1);
  264.         
  265.         AIEnableInstinct(t_commie00[RIGHT_ROOM_COMMIE_INDEX], "dodge", 1);
  266.         AIEnableInstinct(t_commie00[RIGHT_ROOM_COMMIE_INDEX], "humancombatmove", 1);
  267.         AIEnableInstinct(t_commie00[RIGHT_ROOM_COMMIE_INDEX], "basicfollow", 1);
  268.         AIEnableInstinct(t_commie00[RIGHT_ROOM_COMMIE_INDEX], "circlestrafe", 1);
  269.         AIEnableInstinct(t_commie00[RIGHT_ROOM_COMMIE_INDEX], "listen", 1);
  270.  
  271.         b_MessengerSent=1;
  272.  
  273.         // Flee to waypoint
  274.         AISetSubMode(t_commie00[MESSENGER_COMMIE_INDEX], 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION. Required for FleeToWpnt
  275.         AIFleeToWpnt(t_commie00[MESSENGER_COMMIE_INDEX], MESSENGER_FLEE_TO_WAYPOINT); 
  276.     }
  277.  
  278.     return;
  279.  
  280. # ========================================================================================
  281. ActivateWaypoints:
  282.  
  283.     if (b_WpntsActive)
  284.     {
  285.         return;
  286.     }
  287.     b_WpntsActive = 1;
  288.  
  289.     for (n_pos = 0; n_pos < NUM_WAYPOINTS; n_pos = n_pos+1)
  290.     {
  291.         AISetWpnt(t_ghost00[n_pos], n_pos);     //assigns each waypoint slot a ghost object 
  292.     }
  293.  
  294.     // LINK WAYPOINTS TO FORM THE GRID STRUCTURE
  295.     AIConnectWpnts(0, 1);
  296.     AIConnectWpnts(1, 2);
  297.     AIConnectWpnts(2, 3);
  298.     AIConnectWpnts(3, 4);
  299.     AIConnectWpnts(4, 7);
  300.     AIConnectWpnts(5, 6);
  301.     AIConnectWpnts(5, 7);
  302.     AIConnectWpnts(3, 8);
  303.     AIConnectWpnts(8, 9);
  304.     AIConnectWpnts(9, 10);
  305.     AIConnectWpnts(10, 11);
  306.     AIConnectWpnts(11, 12);
  307.     AIConnectWpnts(12, 13);
  308.     AIConnectWpnts(13, 14);
  309.     AIConnectWpnts(14, 15);
  310.     AIConnectWpnts(15, 16);
  311.     AIConnectWpnts(15, 17);
  312.  
  313.  
  314.     #SET ALL HUNTING COMMIES TO USE THE GRID FOR FLEEING AND PURSUING
  315.     #print("Instinct set");
  316.     for (n_pos = 0; n_pos < n_NumHuntingCommies; n_pos = n_pos+1)
  317.     {       
  318.         if (t_commie00[n_pos] != -1)
  319.         {
  320.             AISetInstinctWpntMode(t_commie00[n_pos]); 
  321.         }
  322.     }
  323.  
  324.     return;
  325.     
  326. # ========================================================================================
  327. DeactivateWaypoints:
  328.  
  329.     if (!b_WpntsActive)
  330.     {
  331.         return;
  332.     }
  333.     b_WpntsActive = 0;
  334.  
  335.     for (n_pos = 0; n_pos < n_NumHuntingCommies; n_pos = n_pos+1)
  336.     {       
  337.         if (t_commie00[n_pos] != -1)
  338.         {
  339.             AIEnableInstinct(t_commie00[n_pos], "roam", 0); // Don't want them milling about without waypoints
  340.             AIClearInstinctWpntMode(t_commie00[n_pos]); 
  341.         }
  342.     }
  343.  
  344.     return;
  345.  
  346. end
  347.  
  348.